libxc: fix memory leak in migration v2
authorWei Liu <wei.liu2@citrix.com>
Sun, 26 Jul 2015 21:34:54 +0000 (22:34 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 27 Jul 2015 07:55:00 +0000 (08:55 +0100)
commit20960a081ad23e0a5d1fd48fd84cff9f81e7cc6c
treed78f443448b57abc83160e382abc850254b86c0e
parent19b17e240c5f31eb1ff744946ce75afa729bfe91
libxc: fix memory leak in migration v2

Originally there was only one counter to keep track of pages. It was
used erroneously to keep track of how many pages were mapped and how
many pages needed to be sent. In the end munmap(2) always had 0 as the
length argument, which resulted in leaking the mapping.

This problem was discovered on 32bit toolstack because 32bit applications
have notably smaller address space. In fact this bug affects 64bit
toolstack too.

Use a separate counter to keep track of the number of mapped pages to
solve this problem.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxc/xc_sr_save.c